<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@include file="/static/common/taglib.jsp" %>
<%@include file="../../public/commonJs.jsp" %>
<%@include file="../../public/commonCss.jsp" %>
<div class="layui-form" style="padding: 20px">
    <blockquote class="layui-elem-quote">${giveWork.userName}</blockquote>
    <input type="hidden" value="${giveWork.id}" name="id">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label"> <span class="fontRed">*</span>车组号：</label>
            <div class="layui-input-inline">
                <input name="trainNum" type="number" lay-verify="required" class="layui-input"
                       value="${giveWork.trainNum}">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label"> <span class="fontRed">*</span>叫班：</label>
            <div class="layui-input-inline">
                <input name="remindTime" type="time" lay-verify="required" class="layui-input"
                       value="${giveWork.remindTime}">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label"></label>
            <div class="layui-input-inline">
                <button class="layui-btn js_submit" lay-submit="" lay-filter="demo1">保存</button>
            </div>
        </div>
    </div>

</div>
<script type="text/javascript">
    var form = layui.form();

    $(function () {
        initKeyDown();
    });

    function initKeyDown() {
        document.onkeydown = function (e) {
            var ev = document.all ? window.event : e;
            if (ev.keyCode == 13) {
                $(".js_submit").click();
            }
        }
    }

    //监听提交
    form.on('submit(demo1)', function (data) {
        var dataStr = {
            trainNum: $("input[name='trainNum']").val()
        }
        console.log(dataStr);
        console.log(data.field);
        ajaxUtil.postDealCode("${ctx}/giveWorkController/checkTrainNum.action", dataStr, false, function (c) {
            if (!c) {
                layerUtil.fail("车组号不存在");
                return;
            } else {
                ajaxUtil.post("${ctx}/giveWorkController/updateGiveWork.action", data.field, true, function (r) {
                    parent.layer.closeAll();
                    parent.loadTableData();
                })
            }
        });
        return false;
    });
    form.render();
</script>
